class Solution
{
public:
    int firstUniqChar(string s)
    {
        vector<int> fisrtOccur(26, -1);
        int n = s.size();
        for (int i = 0; i < n; ++i)
        {
            char c = s[i];
            if (fisrtOccur[c - 'a'] == -1)
            {
                fisrtOccur[c - 'a'] = i;
            }
            else
            {
                fisrtOccur[c - 'a'] = -2;
            }
        }
        int result = n;
        for (int occur : fisrtOccur)
        {
            if (occur >= 0)
            {
                result = min(result, occur);
            }
        }
        if (result == n)
        {
            return -1;
        }
        return result;
    }
};